<template>
	<view class="app-explain">
		<view>{{text}}</view>
		<view style="margin-top: 20rpx;">
			<u-button @click='copyText'  type="primary">一键复制</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text: ''
			}
		},
		onLoad(e) {

			let tishi = uni.getStorageSync('tishi');
			this.text = tishi
			console.log('tishi', tishi);
		},
		methods: {
			copyText() {
				uni.setClipboardData({
					data: this.text,
					success: () => {
						uni.getClipboardData({
							success: res => {
								console.log('复制成功，内容为：', res.data)
								return uni.$u.toast('复制成功')
								// 可以在这里添加用户提示复制成功
							}
						});
					},
					fail: () => {
						console.log('复制失败');
						return uni.$u.toast('复制失败')
						// 可以在这里添加用户提示复制失败
					}
				});
			}
		}
	}
</script>

<style lang="less">
	.app-explain {
		font-size: 30rpx;
		color: #666;
		padding: 20rpx;
	}
</style>